ReplaceInPlace Generic Method

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Replace all items in a list or array equal to a particular value with another value. The replacement is done in-place, changing the list.

Namespace: Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax

C#
public static void ReplaceInPlace<T>(
	IList<T> list,
	T itemFind,
	T replaceWith
)
Visual Basic (Declaration)
Public Shared Sub ReplaceInPlace(Of T) ( _
	list As IList(Of T), _
	itemFind As T, _
	replaceWith As T _
)
Visual C++
public:
generic<typename T>
static void ReplaceInPlace (
	IList<T>^ list, 
	T itemFind, 
	T replaceWith
)

Parameters

list
IList<(Of <T>)>
The list or array to process.
itemFind
T
The value to find and replace within .
replaceWith
T
The new value to replace with.

Type Parameters

T

Remarks

The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals.

Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as list.

See Also